<%--
 *  File:    FileContentRuleMain.jsp
 *  @Author: TerryCui 
 *  Date:    2010/07/29
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.FileContentRuleMain"); 
%>



<%
  //init param
  String strModuleName = "CM";  
  String privilegeCode = "E0512";
  String contextPath = request.getContextPath();
  
  boolean bIsEdit = false;
  
  if(request.getParameter("deptid")!= null){
    bIsEdit = true;
  }
%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title>FileContentRuleMain</title>
<PageFlow:CheckPageFlow pageName="p_filecontentrulemain"/>
<%@ include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/PopWindow.js"></script>
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
</head>
<%
	HashMap ruleinfo = (HashMap)pageContext.getAttribute("ruleinfo");
	if(ruleinfo == null || ruleinfo.isEmpty()){
		ruleinfo = new HashMap();
	}  
	Integer filecontentruleid = (Integer)ruleinfo.get("filecontentruleid");
	boolean hasId = !(filecontentruleid==null);
%>
<body>
<script>

function checkInfo(form){
	if(isEmpty(form.filecontentrulecode.value)){
	  alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_ContentRuleCode",false))%>");
	  return false;
	}
	
	if(isEmpty(form.filecontentrulename.value)){
	  alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_ContentRuleName",false) )%>");
	  return false;
	}
	
	if(form.processtype.value == " "){
	  alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_TransType",false) )%>");
	  return false;
	}
	
	return true;
}


function page_done(){
	if(!checkInfo(document.ruleeditform)){
	  return;
	}
	
	ruleeditform.target = "_parent";
	document.ruleeditform.actionname.value = "done";
	isRunning = true;
	document.ruleeditform.submit();
}

function getTableName(){
	document.ruleeditform.tablename.value = "";
	if(document.ruleeditform.processtype.value == " ")
	  return;
	var  datahandler = new  DataHandler() ;
	datahandler.add_params("processtype" , document.ruleeditform.processtype.value,"Integer");
	datahandler.getResult("tablename","document.ruleeditform.tablename"); 
	datahandler.add_job("j_gettablename") ;
	datahandler.runDataHandler ();
}
</script>
<iframe name="reloadHandler" style="display:none" ></iframe>
<form name="ruleeditform" method="post" action="<%=contextPath%>/Dispatcher" target="_parent">
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="2" class="summary_top"></td>
        </tr>
        <tr>
          <td colspan="2"><img src="<%=contextPath%>/images/<%= strLanguageCode %>/quote.gif" width="16" height="11">
            <%= label.getLabelName("L_NEContentRule") %></td>
        </tr>
      </table>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">

	    <input type="hidden" name="pagename" value="p_filecontentrulemain">
	    <input type="hidden" name="actionname">
	    <custom:hidden name="ruleinfo" property="filecontentruleid"/> 
        <tr>
          <td class="need" width="150">&nbsp;<%= label.getLabelName("L_ContentRuleCode") %><%= label.getLabelName("L_Colon") %></td>
          <td>
          <%if(filecontentruleid == null){ %>
          	<custom:text name="ruleinfo" property="filecontentrulecode" size="25"/>
          <%}else{ %>
          	<custom:write name="ruleinfo" property="filecontentrulecode"/>
          <%} %>
          </td>
          <td class="need" width="150">&nbsp;<%= label.getLabelName("L_ContentRuleName") %><%= label.getLabelName("L_Colon") %></td>
          <td><custom:text name="ruleinfo" property="filecontentrulename" size="25"/></td>
        </tr>
        <tr> 
          <td class="need" width="150">&nbsp;<%= label.getLabelName("L_TransType") %><%= label.getLabelName("L_Colon") %></td>
          <td>
            <custom:selectdic disabled="<%=hasId %>" defaultValueCost=" " onchange="getTableName()" defaultValue="------"  name="ruleinfo" property="processtype" dictType="DataCleanType"/>
          </td>
          <td class="td-text" width="150">&nbsp;<%= label.getLabelName("L_TableName") %><%= label.getLabelName("L_Colon") %></td>
          <td>
            <custom:text name="ruleinfo" property="tablename" size="15" style="border:0" readonly="true"/>
          </td>
        </tr>                
      </table>

    </td>
  </tr>
  <tr>
    <td class="summary_top"></td>
  </tr>
  <tr>
    <td class="td_center">
    <a onclick="page_done()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a>
    </td>
  </tr>
</table>
</form>
</body>
</html>